package yongjian.drp.dao.Impl;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.SessionFactory;
import org.springframework.stereotype.Component;

import yongjian.drp.dao.ChartDao;

@Component("chartDao")
public class CahrtDaoImpl implements ChartDao{
	
	private SessionFactory sessionFactory;
	
	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}
	@Resource
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	@Override
	public List<Object[]> getDataSet() {
		List<Object[]> objects = (List<Object[]>)sessionFactory.getCurrentSession().createQuery("select i.category,count(*) from Item i group by i.category").list();
		return objects;
	}

}
